<template>
    <div class="fullscreen" >
        <Button class="btnn" type="primary" size="large" @click="myclass()" style="background: #d68b89">{{ $t("m.fǎnhuíshǒuyè") }}</Button>
        <Button class="btnn" type="primary" size="large"  @click="chaxun()">{{ $t("m.cháxún") }}</Button>
        <Modal v-model="deng" width="540" class="center" footer-hide>
            <div class="blank"></div>
            <label>{{ $t("m.sōusuǒkuāng") }}</label>
            <div class="blank"></div>

           <Row>
               <Col span="8">{{ $t("m.shēnfènzhènghào") }}：（<span style="color:red;">{{ $t("m.bìtián") }}</span>）</Col>
               <Col span="16"><Input v-model="icn"></Input></Col>
           </Row>
            <br>
            <Row>
                <Col span="8">{{ $t("m.shǒujīhào") }}：（<span style="color:red;">{{ $t("m.bìtián") }}</span>）</Col>
                <Col span="16"><Input v-model="phone"></Input></Col>
            </Row>
            <br>
            <Row>
                <Col span="8">{{ $t("m.xìngmíng") }}：</Col>
                <Col span="16"><Input v-model="name"></Input></Col>
            </Row>
            <br>
            <Row>
                <Col span="8">{{ $t("m.ānzhuōshèbèiAdvertisingID") }}：</Col>
                <Col span="16"><Input v-model="aid"></Input></Col>
            </Row>
            <br>
            <Row>
                <Col span="8">{{ $t("m.píngguǒshèbèiIDFA") }}：</Col>
                <Col span="16"><Input v-model="iid"></Input></Col>
            </Row>
            <br>
            <Row>
                <Col span="8">{{ $t("m.yóuxiāngdìzhǐ") }}：</Col>
                <Col span="16"><Input v-model="email"></Input></Col>
            </Row>
            <br>
            <Row>
                <Col span="8">{{ $t("m.IPdìzhǐ") }}：</Col>
                <Col span="16"><Input v-model="ip"></Input></Col>
            </Row>
            <br>
            <Row>
                <Col span="8">{{ $t("m.WIFIMacdìzhǐ") }}：</Col>
                <Col span="16"><Input v-model="wm"></Input></Col>
            </Row>
            <div class="blank"></div>
            <div style="height: 20px"></div>
            <Row>
                <Col span="4" push="8" v-if="blacklistDataVutton"><Button @click="chaxun2" type="success">{{ $t("m.right") }}</Button></Col>
                <Col span="4" push="8" v-else><Button  type="success" loading>{{ $t("m.cháxúnzhōng") }}</Button></Col>
                <Col span="4" push="8"> <Button @click="cancel" >{{ $t("m.cancel") }}</Button></Col>
            </Row>

        </Modal>
        <Table :columns="columns1" :data="blacklistData" class="blacklistDataStyle" border>

        </Table>



    </div>
</template>

<script>
    export default {
        name: "LoginRegister",
        data(){
            return{
                columns1: [
                    {
                        title: this.$t('m.míngchēng'),
                        key: 'name',
                    },
                    {
                        title: this.$t('m.jiéguǒ'),
                        key: 'show',
                    }
                ],
                blacklistData:[],
                blacklistDataVutton:true,
                deng:false,
                zhu:false,
                icn: '',
                phone: '',
                name:'',
                aid:'',
                iid:'',
                email:'',
                ip:'',
                wm:'',
                blacklistData: [
                    { "name": this.$t('m.shēnfènzhènghào'), "show": '',val:['blIdHighRisk',  'blIdMidRisk',  'blIdLowRisk',  'blIdAgency',]},
                    { "name": this.$t('m.shǒujīhào'), "show": '',val:['blMobHighRisk',  'blMobMidRisk',  'blMobLowRisk',  'blMobAgency',]},
                    { "name": this.$t('m.ānzhuōshèbèiAdvertisingID'), "show": '',val:['blAaidHighRisk',  'blAaidMidRisk',  'blAaidLowRisk',  'blAaidAgency',]},
                    { "name": this.$t('m.píngguǒshèbèiIDFA'), "show": '',val:['blIdfaHighRisk',  'blIdfaMidRisk',  'blIdfaLowRisk',  'blIdfaAgency',]},
                    { "name": this.$t('m.yóuxiāngdìzhǐ'), "show": '',val:['blEmailHighRisk',  'blEmailMidRisk',  'blEmailLowRisk',  'blEmailAgency',]},
                    { "name": this.$t('m.IPdìzhǐ'), "show": '',val:['blIpHighRisk',  'blIpMidRisk',  'blIpLowRisk',  'blIpAgency',]},
                    { "name": this.$t('m.WIFIMacdìzhǐ'), "show": '',val:['blWmacHighRisk',  'blWmacMidRisk',  'blWmacLowRisk',  'blWmacAgency',]},
                ],


            }
        },
        methods:{
          myclass(){
            this.$router.push('/home');
          },
            chaxun2(){
                this.blacklistDataVutton = false
                this.$http.post('/api/laocai/blacklist/goldfinanceCheckout',{
                    idCardNo: this.icn,
                    mobileNo: this.phone,
                    name: this.name,
                    mobileAdvertisingId: this.aid,
                    mobileIdfa: this.iid,
                    email: this.email,
                    ip: this.ip,
                    wifiMac: this.wm
                }).then((res)=>{
                  for (const key in this.blacklistData) {
                      this.blacklistData[key].show = ''
                  }
                  let dataObj =  res.data.result.data
                  // 状态判断
                  if (dataObj.flagBlackList==1) { 
                    for (const i in dataObj) {
                      if (dataObj[i] >0) {
                        for (const key in this.blacklistData) {
                          let hintText = ''
                          if (this.blacklistData[key].val.indexOf(i)==0) {
                            hintText = this.$t('m.gāofēngxiǎn')+' '
                          }
                          if (this.blacklistData[key].val.indexOf(i)==1) {
                            hintText = this.$t('m.zhòngfēngxiǎn')+' '
                          }
                          if (this.blacklistData[key].val.indexOf(i)==2) {
                            hintText = this.$t('m.dīfēngxiǎn')+' '
                          }
                          if (this.blacklistData[key].val.indexOf(i)==3) {
                            hintText = this.$t('m.yísìzhōngjiè')+' '
                          }
                          this.blacklistData[key].show += hintText
                        }                       
                      }
                    }                    
                    for (const key in this.blacklistData) {
                      if (!this.blacklistData[key].show) {
                        this.blacklistData[key].show = this.$t('m.Wú')                        
                      }
                    }                    
                    this.$Message.warning(this.$t('m.cháxúnchénggōng'));
                  } 
                  if (dataObj.flagBlackList==0) {
                    this.$Message.warning(this.$t('m.wèipǐpèishàngwúshūchū'));
                    for (const key in this.blacklistData) {
                        this.blacklistData[key].show = this.$t('m.Wú')
                    }
                  } 
                  if (dataObj.flagBlackList==98){
                    this.$Message.warning(this.$t('m.yònghùshūrùxìnxībùzú'));                  
                  } 
                  if (dataObj.flagBlackList==99){
                    this.$Message.warning(this.$t('m.xìtǒngyìcháng'));                
                  }
                  this.deng = false
                  this.blacklistDataVutton =true
                  return
                })
                .catch(error => {
                  this.blacklistDataVutton =true
                    this.$Message.warning(this.$t('m.qǐngqiúchūcuò'));
                });
            },
            chaxun(){
                this.icn= '',
                this.phone= '',
                this.name='',
                this.aid='',
                this.iid='',
                this.email='',
                this.ip='',
                this.wm='',
                this.deng = true

            },
            zhuce(){
                this.zhu = true

            },
            cancel(){
                this.deng = false
            }
        }
    }
</script>

<style scoped>
    .blank{
        height: 30px
    }
    .center{
        display: flex;
        flex-wrap: wrap;
        flex-direction: row;
        text-align: center;
    }
    .input{
        width: 150px;
    }
    .fullscreen{
        width: 100%;
        height: 100%;
    }
    .btnn{
        margin-top:30px;
        margin-left: 30px;
    }
    .blacklistDataStyle{
      margin: 30px auto;
    }
</style>
